package com.weaving.monitor.controller;

import com.weaving.monitor.dto.MachineStatusDto;
import com.weaving.monitor.dto.PendingPlanDto;
import com.weaving.monitor.dto.MachineDetailDto;
import com.weaving.monitor.service.MachineService;
import com.weaving.monitor.service.PendingPlanService;
import com.weaving.monitor.service.MachineDetailService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import java.util.List;

@RestController
@RequestMapping("/api/monitor")
@RequiredArgsConstructor
@CrossOrigin(origins = "*")
public class MonitorController {
    
    private final MachineService machineService;
    private final PendingPlanService pendingPlanService;
    private final MachineDetailService machineDetailService;
    
    @GetMapping("/machines")
    public List<MachineStatusDto> getAllMachineStatus() {
        return machineService.getAllMachineStatus();
    }
    
    @GetMapping("/machines/{machineNumber}")
    public MachineStatusDto getMachineStatus(@PathVariable Integer machineNumber) {
        return machineService.getMachineStatus(machineNumber);
    }
    
    @GetMapping("/machines/{machineNumber}/detail")
    public MachineDetailDto getMachineDetail(@PathVariable Integer machineNumber) {
        return machineDetailService.getMachineDetail(machineNumber);
    }
    
    @GetMapping("/pending-plans")
    public PendingPlanDto getAllPendingPlans() {
        return pendingPlanService.getAllPendingPlans();
    }
} 